package com.faceCaptor.common;

public class Result<T> {
    private String code;
    private String message;
    private T data;

    public Result() {
    }

    public Result(String code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
    
    public Result(ResultCode resultCode){
    	this.code=resultCode.getCode();
    	this.message=resultCode.getMessage();
    }

    public static Result success(){
        Result res = new Result();
        res.setResultCode(ResultCode.SUCCESS);
        return res;
    }

    public static Result success(ResultCode resultCode) {
        Result result = new Result();
        result.setResultCode(resultCode);
        result.setMessage(resultCode.getMessage());
        return result;
    }
    public static Result success(ResultCode resultCode, Object data) {
        Result result = new Result();
        result.setResultCode(resultCode);
        result.setData(data);
        return result;
    }

    public static Result success(Object data) {
        Result result = new Result();
        result.setResultCode(ResultCode.SUCCESS);
        result.setData(data);
        return result;
    }

    public static Result failure(ResultCode resultCode) {
        Result result = new Result();
        result.setResultCode(resultCode);
        result.setMessage(resultCode.getMessage());
        return result;
    }

    public void setResultCode(ResultCode code) {
        this.code = code.getCode();
        this.message = code.getMessage();
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
